<%@ page import="com.interfaces.*" %>
<%@ page import="java.util.Random" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<!--
This is a starter template page. Use this page to start your new project from
scratch. This page gets rid of all links and provides the needed markup only.
-->
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>签证系统</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">

    <%
        String path = request.getContextPath();
        path = "/".equals(path)?"":path;
        request.setAttribute("path", path);
    %>
    <script type="text/javascript">
        var path = "${path}";
    </script>

    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="${path}/public/adminlte/bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="${path}/public/font-awesome-4.7.0/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="${path}/public/ionicons/ionicons.min.css">
    <!-- DataTables -->
    <link rel="stylesheet" href="${path}/public/adminlte/plugins/datatables/dataTables.bootstrap.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="${path}/public/adminlte/dist/css/AdminLTE.min.css">
    <!-- AdminLTE Skins. We have chosen the skin-blue for this starter
          page. However, you can choose any other skin. Make sure you
          apply the skin class to the body tag so the changes take effect.
    -->
    <link rel="stylesheet" href="${path}/public/adminlte/dist/css/skins/_all-skins.min.css">

    <link rel="stylesheet" href="${path}/css/common.css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<!--
BODY TAG OPTIONS:
=================
Apply one or more of the following classes to get the
desired effect
|---------------------------------------------------------|
| SKINS         | skin-blue                               |
|               | skin-black                              |
|               | skin-purple                             |
|               | skin-yellow                             |
|               | skin-red                                |
|               | skin-green                              |
|---------------------------------------------------------|
|LAYOUT OPTIONS | fixed                                   |
|               | layout-boxed                            |
|               | layout-top-nav                          |
|               | sidebar-collapse                        |
|               | sidebar-mini                            |
|---------------------------------------------------------|
-->
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

    <!-- Main Header -->
    <header class="main-header">

        <!-- Logo -->
        <a href="index2.html" class="logo">
            <!-- mini logo for sidebar mini 50x50 pixels -->
            <span class="logo-mini"><b>签</b>证</span>
            <!-- logo for regular state and mobile devices -->
            <span class="logo-lg"><b>签证</b>系统</span>
        </a>

        <!-- Header Navbar -->
        <nav class="navbar navbar-static-top" role="navigation">
            <!-- Sidebar toggle button-->
            <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
                <span class="sr-only">Toggle navigation</span>
            </a>
            <!-- Navbar Right Menu -->
            <div class="navbar-custom-menu">
                <ul class="nav navbar-nav">
                    <!-- Messages: style can be found in dropdown.less-->
                    <!-- /.messages-menu -->

                    <!-- Notifications Menu -->
                    <!-- Tasks Menu -->
                    
                    <!-- User Account Menu -->
                    
                    <li class="dropdown user user-menu" id="updatePwd">
                        <!-- Menu Toggle Button -->
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                            <span class="hidden-xs">修改密码</span>
                        </a>
                    </li>
                    <li class="dropdown user user-menu">
                        <!-- Menu Toggle Button -->
                        <a href="${path}<%=SysLoginController.URL_LOGOUT%>">
                            <span class="hidden-xs">注销</span>
                        </a>
                    </li>
                    <!-- Control Sidebar Toggle Button -->
                    
                </ul>
            </div>
        </nav>
    </header>
    <!-- Left side column. contains the logo and sidebar -->
    <aside class="main-sidebar">

        <!-- sidebar: style can be found in sidebar.less -->
        <section class="sidebar">

            <!-- Sidebar user panel (optional) -->
            <div class="user-panel">
                <div class="pull-left image">
                    <img src="${path}/public/adminlte/dist/img/user2-160x160.jpg" class="img-circle" alt="User Image">
                </div>
                <div class="pull-left info">
                    <p id="userName"></p>
                    
                    <a href="#"><i class="fa fa-circle text-success"></i> Online</a>
                </div>
            </div>

            <!-- search form (Optional) 
            <!--
            <form action="#" method="get" class="sidebar-form">
                <div class="input-group">
                    <input type="text" name="q" class="form-control" placeholder="Search...">
                    <span class="input-group-btn">
                <button type="submit" name="search" id="search-btn" class="btn btn-flat"><i class="fa fa-search"></i>
                </button>
              </span>
                </div>
            </form>-->
            <!-- /.search form -->

            <!-- Sidebar Menu -->
            <ul class="sidebar-menu">
                <li class="header">主菜单</li>
                <li class="active"><a href="#" id="menuGuarantee"><i class="fa fa-link"></i> <span>招保信息管理</span></a></li>
                <li class="active"><a href="#" id="menuVisaInfo"><i class="fa fa-link"></i> <span>送签信息管理</span></a></li>
                <li class="active" id="willHide1"><a href="#" id="menuSendAgent"><i class="fa fa-link"></i> <span>送签社信息管理</span></a></li>
                
                <li class="active" id="willHide2"><a href="#" id="menuTravelAgent"><i class="fa fa-link"></i> <span>旅行社信息管理</span></a></li>
                <li class="treeview" id="willHide3">
                    <a href="#"><i class="fa fa-link"></i> <span>系统管理</span>
                        <span class="pull-right-container">
                            <i class="fa fa-angle-left pull-right"></i>
                        </span>
                    </a>
                    <ul class="treeview-menu" id="willHide4">
                        <li class="active" id="menuUser"><a href="#">用户管理</a></li>
                        <li class="active" id="menuConfig"><a href="#">参数管理</a></li>
                        <li class="active" id="menuSysLog"><a href="#">用户操作日志</a></li> 
                    </ul>
               </li>
               <li class="active"><a href="#" id="menuStatistica"><i class="fa fa-link"></i> <span>报表统计</span></a></li>
            <!-- /.sidebar-menu -->
        </section>
        <!-- /.sidebar -->
    </aside>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">

        <div class="nav-tabs-custom">
            <ul class="nav nav-tabs nav-tabs1">
            </ul>
            <div class="tab-content tab-content1">
            </div>
            <!-- /.tab-content -->
        </div>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->

    <!-- Main Footer -->
    <footer class="main-footer">
        <!-- To the right -->
        <div class="pull-right hidden-xs">
            Anything you want
        </div>
        <!-- Default to the left -->
        <strong>Copyright &copy; 2016 <a href="#">Company</a>.</strong> All rights reserved.
    </footer>

    <!-- Control Sidebar -->
    <aside class="control-sidebar control-sidebar-dark">
        <!-- Create the tabs -->
        <ul class="nav nav-tabs nav-justified control-sidebar-tabs">
            <li class="active"><a href="#control-sidebar-home-tab" data-toggle="tab"><i class="fa fa-home"></i></a></li>
            <li><a href="#control-sidebar-settings-tab" data-toggle="tab"><i class="fa fa-gears"></i></a></li>
        </ul>
        <!-- Tab panes -->
        <div class="tab-content">
            <!-- Home tab content -->
            <div class="tab-pane active" id="control-sidebar-home-tab">
                <h3 class="control-sidebar-heading">Recent Activity</h3>
                <ul class="control-sidebar-menu">
                    <li>
                        <a href="javascript:;">
                            <i class="menu-icon fa fa-birthday-cake bg-red"></i>

                            <div class="menu-info">
                                <h4 class="control-sidebar-subheading">Langdon's Birthday</h4>

                                <p>Will be 23 on April 24th</p>
                            </div>
                        </a>
                    </li>
                </ul>
                <!-- /.control-sidebar-menu -->

                <h3 class="control-sidebar-heading">Tasks Progress</h3>
                <ul class="control-sidebar-menu">
                    <li>
                        <a href="javascript:;">
                            <h4 class="control-sidebar-subheading">
                                Custom Template Design
                                <span class="pull-right-container">
                  <span class="label label-danger pull-right">70%</span>
                </span>
                            </h4>

                            <div class="progress progress-xxs">
                                <div class="progress-bar progress-bar-danger" style="width: 70%"></div>
                            </div>
                        </a>
                    </li>
                </ul>
                <!-- /.control-sidebar-menu -->

            </div>
            <!-- /.tab-pane -->
            <!-- Stats tab content -->
            <div class="tab-pane" id="control-sidebar-stats-tab">Stats Tab Content</div>
            <!-- /.tab-pane -->
            <!-- Settings tab content -->
            <div class="tab-pane" id="control-sidebar-settings-tab">
                <form method="post">
                    <h3 class="control-sidebar-heading">General Settings</h3>

                    <div class="form-group">
                        <label class="control-sidebar-subheading">
                            Report panel usage
                            <input type="checkbox" class="pull-right" checked>
                        </label>

                        <p>
                            Some information about this general settings option
                        </p>
                    </div>
                    <!-- /.form-group -->
                </form>
            </div>
            <!-- /.tab-pane -->
        </div>
    </aside>
    <!-- /.control-sidebar -->
    <!-- Add the sidebar's background. This div must be placed
         immediately after the control sidebar -->
    <div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->

<!-- REQUIRED JS SCRIPTS -->

<!-- jQuery 2.2.3 -->
<script src="${path}/public/adminlte/plugins/jQuery/jquery-2.2.3.min.js"></script>
<!-- Bootstrap 3.3.6 -->
<script src="${path}/public/adminlte/bootstrap/js/bootstrap.min.js"></script>
<!-- DataTables -->
<script src="${path}/public/adminlte/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="${path}/public/adminlte/plugins/datatables/dataTables.bootstrap.min.js"></script>
<!-- SlimScroll -->
<script src="${path}/public/adminlte/plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="${path}/public/adminlte/plugins/fastclick/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="${path}/public/adminlte/dist/js/app.min.js"></script>

<!-- Optionally, you can add Slimscroll and FastClick plugins.
     Both of these plugins are recommended to enhance the
     user experience. Slimscroll is required when using the
     fixed layout. -->
<!-- page script -->
<script>
    var addTab = function (obj) {
        id ="tab_"+ obj.id;

        $(".active").removeClass("active");
//如果TAB不存在，创建一个新的TAB
        if (!$("#"+ id)[0]) {
//固定TAB中IFRAME高度
            mainHeight = $(document.body).height() - 95;
//创建新TAB的title
            title = '<li role="presentation" id="tab_' + id + '"><a href="#' + id + '" aria-controls="' + id + '" role="tab" data-toggle="tab">' + obj.title;
//是否允许关闭
            if (obj.close) {
                //title += ' <i class="icon-cancel" tabclose="' + id + '">x</i>';
                title += '<button type="button" class="close" aria-label="Close" tabclose="' + id + '" style="width:0px; margin-left:10px;">';
                title += '<span aria-hidden="true" style="color:red">&times;</span>';
                title += '</button>';
            }
            title += '</a></li>';
//是否指定TAB内容
            if (obj.content) {
                content = '<div role="tabpanel" class="tab-pane" id="' + id + '">' + obj.content + '</div>';
            } else {//没有内容，使用IFRAME打开链接
                content = '<div role="tabpanel" class="tab-pane" id="' + id + '"><iframe id="s_'+id+'" src="' + obj.url + '" width="100%" height="' + mainHeight +
                    '" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="yes" allowtransparency="yes"></iframe></div>';
            }
//加入TABS
            $(".nav-tabs1").append(title);
            $(".tab-content1").append(content);
        }else{
            $(".nav-tabs1").append($("#tab_"+ id));
            $(".tab-content1").append($("#"+ id));
        }
//激活TAB
        $("#tab_"+ id).addClass('active');
        $("#"+ id).addClass("active");
    };

    var closeTab = function (id) {
//如果关闭的是当前激活的TAB，激活他的前一个TAB
        if ($("li.active").attr('id') =="tab_"+ id) {
            //此处存在问题，如果前一个tab已经关闭，则tab显示空白
            //应该寻找前一个存在的tab,或者将存在的tab记录至队列中，管理队列，方便切换
            if($("#tab_"+ id).prev()[0]==undefined){
                if($("#tab_"+ id).next()[0]==undefined){//前后都没有，唯一一个
                
                }else{//没有前一个，切换至后一个
                    $("#tab_"+ id).next().addClass('active');
                    $("#"+ id).next().addClass('active');
                }
            }else{//有前一个，切换至前一个
                $("#tab_"+ id).prev().addClass('active');
                $("#"+ id).prev().addClass('active');
            }
        }
//关闭TAB
        $("#tab_"+ id).remove();
        $("#"+ id).remove();
    };
    /* ********************** */
    function refresh(arr){
		console.info(arr)
		var childFrame = document.getElementById("s_"+arr);
		childFrame.contentWindow.freshOK();
	}
	function refresh2(arr){
		console.info(arr)
		var childFrame = document.getElementById("s_tab_"+arr);
		childFrame.contentWindow.freshOK();
	}
    var closeAndActiveTab =function(id,targetid){
        if ($("li.active").attr('id') =="tab_tab_"+ id) {
            $("#tab_"+ targetid).addClass('active');
            $("#"+ targetid).addClass('active');
        }
        //关闭TAB
        $("#tab_tab_"+ id).remove();
        $("#tab_"+ id).remove();
    }; 
    var justClose =function(id){
    //关闭TAB
        $("#tab_tab_"+ id).remove();
        $("#tab_"+ id).remove();
    }; 
    /*  ***********************************/  
    var closeAndSwitchTab = function (id,targetid) {
//如果关闭的是当前激活的TAB，激活指定TAB
        if ($("li.active").attr('id') =="tab_"+ id) {
            $("#tab_"+ targetid).addClass('active');
            $("#"+ targetid).addClass('active');
        }
        //关闭TAB
        $("#tab_"+ id).remove();
        $("#"+ id).remove();
    };

    $(function () {
    	$("#willHide1").hide();
		$("#willHide2").hide();
		$("#willHide3").hide();
		$("#willHide4").hide(); 
        $(".nav-tabs1").on("click","[tabclose]", function (e) {
            id = $(this).attr("tabclose");
            closeTab(id);
        });
        var menuVisaInfoID='<%=Math.abs(new Random().nextInt())%>';
        $("#menuVisaInfo").click(function(){
        	addTab({id: menuVisaInfoID, title:"签证信息设置",url:"${path}<%=VisaApplicationInfoController.URL_GOTO_MAIN_PAGE%>?&"+menuVisaInfoID+"&-1", close:true});
        });
        var menuGuaranteeID='<%=Math.abs(new Random().nextInt())%>';
        $("#menuGuarantee").click(function(){
        	addTab({id: menuGuaranteeID, title:"招保信息设置",url:"${path}<%=GuaranteeController.URL_GOTO_MAIN_PAGE%>?&"+menuGuaranteeID+"&-1", close:true});
        });
        var menuSendAgentID='<%=Math.abs(new Random().nextInt())%>';
        $("#menuSendAgent").click(function(){
        	addTab({id: menuSendAgentID, title:"送签社信息设置",url:"${path}<%=SendAgentController.URL_GOTO_MAIN_PAGE%>?&"+menuSendAgentID+"&-1", close:true});
        });
        var menuTravelAgentID='<%=Math.abs(new Random().nextInt())%>';
        $("#menuTravelAgent").click(function(){
        	addTab({id: menuTravelAgentID, title:"旅行社信息设置",url:"${path}<%=TravelAgentController.URL_GOTO_MAIN_PAGE%>?&"+menuTravelAgentID+"&-1", close:true});
        });
        var menuStatisticaID='<%=Math.abs(new Random().nextInt())%>';
        $("#menuStatistica").click(function(){
        	addTab({id: menuStatisticaID, title:"报表统计信息设置",url:"${path}<%=StatisticaController.URL_GOTO_MAIN_PAGE%>?&"+menuStatisticaID+"&-1", close:true});
        });
        var menuUserID='<%=Math.abs(new Random().nextInt())%>';                     
        $("#menuUser").click(function () {
            addTab({id: menuUserID, title: "用户管理", url:"${path}<%=UserController.URL_GOTO_MAIN_PAGE%>?&"+menuUserID+"&-1", close: true});
        });
        var menuConfigID='<%=Math.abs(new Random().nextInt())%>';                     
        $("#menuConfig").click(function () {
            addTab({id: menuConfigID, title: "参数管理", url:"${path}<%=SysConfigController.URL_GOTO_MAIN_PAGE%>?&"+menuConfigID+"&-1", close: true});
        });
        var menuSysLogID='<%=Math.abs(new Random().nextInt())%>';                     
        $("#menuSysLog").click(function () {
            addTab({id: menuSysLogID, title: "用户操作日志", url:"${path}<%=SysLogController.URL_GOTO_MAIN_PAGE%>?&"+menuSysLogID+"&-1", close: true});
        });
    });
    var userNames = document.getElementById("userName");
    var nameUser="";
	$.ajax({
		type: "POST",
		url: "${path}<%=UserController.URL_NAME%>",
		async:false,
		success:function(data){
		console.info(data);
		nameUser=data;
		}
	});
	var user={};
	 
	    $.ajax({
		type: "POST",
		url: "${path}<%=UserController.URL_USER%>",
		async:true,
		success:function(data){
		 user1=JSON.parse(data);
		 user=eval(user1);
		 console.info(user);
		 var flag=0;
		for(var i=0;i<user.length;i++){
			console.info(user[i].id+typeof(user[i].id)+"forbefoe")
			if(user[i].id=="1"){
				flag=1;
			}
		}
		if(flag==1){
		$("#willHide1").show();
		$("#willHide2").show();
		$("#willHide3").show();
		$("#willHide4").show(); 
		} 
		} 
	}); 
	
	var nameUser2="你好,"+nameUser.replace(new RegExp("\"","gm"),"");
    userNames.innerText = nameUser2;
    
</script>
</body>
</html>
